import fs, { write } from 'fs'
import { promisify } from 'util'
const readFile = promisify(fs.readFile)
const writeFile = promisify(fs.writeFile)
const JSONHelper = {
  async read(path) {
    const json = await readFile(path, 'utf8')
    if (!json) {
      return null
    }
    return JSON.parse(json)
  },
  async write(path, content) {
    await writeFile(path, JSON.stringify(content), 'utf8')
  }
}
export default JSONHelper
